package com.guli.vodtest;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthRequest;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse;

/**
 * @author zxc
 * @date 2023/04/08 15:40
 **/
// 根据视频id，来获取播放音视频的凭证;
public class VodDemo3 {
    public static void main(String[] args) throws ClientException {
        // 根据视频id，来获取播放视频播放凭证
        // 加密视频：获取到音视频地址是不能够进行播放的，同时也需要获取该加密视频的凭证信息;
        // 1.创建初始化HttpClient对象
        DefaultAcsClient client = VodInit.initVodClient("LTAI5tGoduzd9bgBczsfeL6K", "Bggqknbss9p7o5lUE6sEvVZc3ZuwoL");

        // 2.获取视频凭证的request和response
        GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest();
        GetVideoPlayAuthResponse response = new GetVideoPlayAuthResponse();

        // 3.设置视频id
        request.setVideoId("35e2baa0d5bd71edb0c10674a2ce0102");

        // 4.调用client对象中所封装的方法，以request作为参数进行传递，得到音视频凭证;
        response = client.getAcsResponse(request);

        System.out.println("PlayAuth : " + response.getPlayAuth());
    }
}
